package com.guaoran.common.utils;

import java.util.Arrays;
import java.util.List;

/**
 * @author : 孤傲然
 * @description : TODO 加上描述吧
 * @date :2020/7/7 17:09
 */
public class LoadBanlance {
    public static void main(String[] args) {
        for (int i = 0; i <10; i++) {
            System.out.println(LoadBanlance.GCD(Arrays.asList(4, 5, 6, 7)));

        }
    }
    public static int GCD(List<Integer> snapWeightList)
    {
        int minNum = snapWeightList.get(0);

        // 最大公约数肯定大于等于1，且小于等于最小的那个数。
        // 依次整除，如果余数全部为0说明是一个约数，直到打出最大的那个约数
        int gcd = 1;
        for (int i = 1; i <= minNum; i++)
        {
            boolean isFound = true;
            for (int snapWeight : snapWeightList)
            {
                if (snapWeight % i != 0)
                {
                    isFound = false;
                    break;
                }
            }
            if (isFound)
                gcd = i;
        }
        return gcd;
    }

}
